Imports System.Data.OracleClient

Public Class frmDBEntry

  Private mObjClsAddNewTable As clsAddNewTable
  Private mBlnModifyCondition As Boolean = False
  Private mBlnTableExisted As Boolean = False
  Private mBlnRGnrtTable As Boolean = False
  Private mDrData As OracleDataReader
  Private mCmdData As OracleCommand
  Private mObjFrmColumnNameSelection As frmColumnNameAbbreviation
  Private mArrMemberProperties As New ArrayList
  Dim clsobjGenClas As clsGenClas
  Dim mColumnVrblRef As Integer
  Dim mBlnGnrtAll As Boolean = False
  Public mIntOldTableId As Integer

  Private Sub frmDBEntry_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim lStrQuery As String = ""
    Dim lIntColumnCounter As Integer = 0
    Dim lIntCount As Integer = 0
    Dim lObjClsMemberProperties As clsMemberProperties
    Dim lObjComboSource As New clsComboSource

    mBlnGnrtAll = False

    mPrRefreshConn()

    mObjFrmColumnNameSelection = New frmColumnNameAbbreviation
    cboClntSrvrIndc.SelectedIndex = 0
    cboMdClntSrvrIndc.SelectedIndex = 0

    'ctlColumnsRecord.ColumnCount = 13

    'ctlColumnsRecord.Columns(0).HeaderText = "Column Name"
    'ctlColumnsRecord.Columns(0).Width = 192
    'ctlColumnsRecord.Columns(1).HeaderText = "Column Data Type"
    'ctlColumnsRecord.Columns(1).Width = 250
    'ctlColumnsRecord.Columns(2).HeaderText = "Column Data Type Value Member"
    'ctlColumnsRecord.Columns(2).Visible = False
    'ctlColumnsRecord.Columns(3).HeaderText = "Column Description"
    'ctlColumnsRecord.Columns(3).Width = 192
    'ctlColumnsRecord.Columns(4).HeaderText = "Not Null Indicator"
    'ctlColumnsRecord.Columns(4).Width = 192
    'ctlColumnsRecord.Columns(5).HeaderText = "Length"
    'ctlColumnsRecord.Columns(5).Visible = False
    'ctlColumnsRecord.Columns(6).HeaderText = "Precision"
    'ctlColumnsRecord.Columns(6).Visible = False
    'ctlColumnsRecord.Columns(7).HeaderText = "Basic DT"
    'ctlColumnsRecord.Columns(7).Visible = False
    'ctlColumnsRecord.Columns(8).HeaderText = "Front End Data Type"
    'ctlColumnsRecord.Columns(8).Visible = False
    'ctlColumnsRecord.Columns(9).HeaderText = "Back End Data Type"
    'ctlColumnsRecord.Columns(9).Visible = False
    'ctlColumnsRecord.Columns(10).HeaderText = "Front End Data Category Class"
    'ctlColumnsRecord.Columns(10).Visible = False
    'ctlColumnsRecord.Columns(11).HeaderText = "Client Server Indicator"
    'ctlColumnsRecord.Columns(11).Visible = False
    'ctlColumnsRecord.Columns(12).HeaderText = "Variable Reference"
    'ctlColumnsRecord.Columns(12).Visible = True 'False


    mObjClsAddNewTable = New clsAddNewTable


    lStrQuery = "Select * from TRDX_DATA_CATEGORY_MSTR"

    mCmdData = New OracleCommand(lStrQuery, con)
    mDrData = mCmdData.ExecuteReader

    If IsDBNull(mDrData) = False Then
      While mDrData.Read
        lObjClsMemberProperties = New clsMemberProperties
        lObjClsMemberProperties.mPrpDisplayMember = UCase(mDrData("TDCM_DESC"))
        lObjClsMemberProperties.mPrpValueMember = mDrData("TDCM_DATA_CTGRY")

        lObjClsMemberProperties.mPrpDataLength = IIf((IsDBNull(mDrData("TDCM_DATA_LENGTH"))) _
                                                    , 0 _
                                                    , mDrData("TDCM_DATA_LENGTH"))

        lObjClsMemberProperties.mPrpDataPrecision = IIf((IsDBNull(mDrData("TDCM_DATA_PRECISION"))) _
                                                       , 0 _
                                                       , mDrData("TDCM_DATA_PRECISION"))

        lObjClsMemberProperties.mPrpBasicDataType = mDrData("TDCM_DATABASE_DATA_TYPE")
        lObjClsMemberProperties.mPrpFrontEndDataType = mDrData("TDCM_FRNT_END_DATA_TYPE")
        lObjClsMemberProperties.mPrpBackEndDataType = mDrData("TDCM_BACK_END_DATA_TYPE")
        lObjClsMemberProperties.mPrpFrontEndDataCatgClass = mDrData("TDCM_FRNT_END_DATA_CATEGORY")
        mArrMemberProperties.Add(lObjClsMemberProperties)
      End While

      For lIntCount = 0 To mArrMemberProperties.Count - 1
        cboColumnDataType.Items.Add(mArrMemberProperties.Item(lIntCount))
      Next

      cboColumnDataType.ValueMember = "mPrpValueMember"
      cboColumnDataType.DisplayMember = "mPrpDisplayMember"
    Else
      MessageBox.Show("No Data In Data Category Master Table")
    End If

    cboTableSpaceIndicator.SelectedIndex = 0
    cboNotNullIndc.SelectedIndex = 0


    Dim lObjTableList As New clsAddNewTable
    Dim lTableArrayList As New ArrayList

    lTableArrayList = lObjTableList.mFnTablesList()
    lObjComboSource.mPrpDisplayMember = "ALL"
    lObjComboSource.mPrpValueMember = 0
    lTableArrayList.Insert(0,lObjComboSource)
    ' cboTableNames.Items.Add("ALL")

    'For lIntCnt As Integer = 0 To lTableArrayList.Count - 1
    '  cboTableNames.Items.Add(lTableArrayList(lIntCnt))
    'Next

    cboTableNames.DataSource = lTableArrayList
    cboTableNames.DisplayMember = "mPrpDisplayMember"
    cboTableNames.ValueMember = "mPrpValueMember"

    cboTableNames.SelectedIndex = 0

  End Sub




  Private Sub cmdAddTableDetails_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddTableDetails.Click

    Dim lIntDataGridRowCount As Integer = 0
    Dim lObjClsMemberProperties As clsMemberProperties

    If txtColumnName.Text = "" Then
      MessageBox.Show("Please Specify Column Name")
      txtColumnName.Focus()
      Exit Sub

    End If

    If cboColumnDataType.Text = "" Then
      MessageBox.Show("Please Specify Column Data Type")
      cboColumnDataType.Focus()
      Exit Sub
    End If
    If cboNotNullIndc.Text = "" Then
      MessageBox.Show("Please Specify Column Null Indicator")
      cboNotNullIndc.Focus()
      Exit Sub
    End If

    If mBlnModifyCondition = False Then
      With ctlColumnsRecord
        .Rows.Add(1)
        lIntDataGridRowCount = .RowCount - 1
      End With
    Else
      If ctlColumnsRecord.SelectedRows.Count = 0 Then Exit Sub
      lIntDataGridRowCount = ctlColumnsRecord.CurrentRow.Index
    End If

    lObjClsMemberProperties = cboColumnDataType.SelectedItem

    With ctlColumnsRecord
      .Rows(lIntDataGridRowCount).Cells("clmDel").Value = "Del"
      .Rows(lIntDataGridRowCount).Cells("clmClmName").Value = txtColumnName.Text
      .Rows(lIntDataGridRowCount).Cells("clmClmType").Value = lObjClsMemberProperties.mPrpDisplayMember
      .Rows(lIntDataGridRowCount).Cells("clmClmTypeValueMember").Value = lObjClsMemberProperties.mPrpValueMember
      .Rows(lIntDataGridRowCount).Cells("clmClmDesc").Value = txtColumnDescription.Text
      '.Rows(lIntDataGridRowCount).Cells(4).Value = cboNotNullIndc.Text
      .Rows(lIntDataGridRowCount).Cells("clmLength").Value = lObjClsMemberProperties.mPrpDataLength
      .Rows(lIntDataGridRowCount).Cells("clmPrecision").Value = lObjClsMemberProperties.mPrpDataPrecision
      .Rows(lIntDataGridRowCount).Cells("clmBasicDT").Value = lObjClsMemberProperties.mPrpBasicDataType
      .Rows(lIntDataGridRowCount).Cells("clmFEDataType").Value = lObjClsMemberProperties.mPrpFrontEndDataType
      .Rows(lIntDataGridRowCount).Cells("clmBEDataType").Value = lObjClsMemberProperties.mPrpBackEndDataType
      .Rows(lIntDataGridRowCount).Cells("clmFECategory").Value = lObjClsMemberProperties.mPrpFrontEndDataCatgClass
      .Rows(lIntDataGridRowCount).Cells("clmClientSrvIndc").Value = cboClntSrvrIndc.Text
      .Rows(lIntDataGridRowCount).Cells("clmVariableReference").Value = mColumnVrblRef

    End With

    txtColumnDescription.Text = String.Empty

  End Sub

  Private Sub txtColumnName_GotFocus(ByVal sender As Object, ByVal e As System.EventArgs) Handles txtColumnName.GotFocus
    txtColumnName.SelectAll()
  End Sub

  Private Sub txtNewTableName_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles txtNewTableName.TextChanged
    Me.Refresh()
  End Sub

  Private Sub CmdSave_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CmdSave.Click
    'before add new table,delete existed columns
    Dim lIntTableId As Integer = 0
    Dim lStrTableName As String = String.Empty
    Dim lStrShortName As String = String.Empty

    If tabTable.SelectedIndex = 0 Then
      lStrShortName = txtTableShortName.Text.Trim
      lStrTableName = txtNewTableName.Text.Trim
    ElseIf tabTable.SelectedIndex = 1 Then
      lStrShortName = txtMdTableShortName.Text.Trim
      lStrTableName = txtMdTableName.Text.Trim
    End If

    If mBlnRGnrtTable = True Then
      Dim lStrQuery As String
      mBlnTableExisted = False
      lStrQuery = "Select * from TRDX_TABLES_MSTR where TABM_TABLE_SHORT_NAME = '" + UCase(lStrShortName) + "'"
      lStrQuery = lStrQuery & " And TABM_TABLE_NAME = '" & UCase(lStrTableName) & "'"
      mCmdData = New OracleCommand(lStrQuery, con)
      mDrData = mCmdData.ExecuteReader

      If mDrData.HasRows = True Then
        MsgBox("This Short Name and Table Name Combination Already Exists ... Kindly Change It ", MsgBoxStyle.Critical, gCONST_MSG_HEADER)
        Exit Sub
      End If

    End If

    If mBlnTableExisted Then
      mObjClsAddNewTable.mPrRemoveTableDetails(UCase(lStrTableName))
    End If
    mObjClsAddNewTable.mPrpRgnrt = mBlnRGnrtTable

    lIntTableId = mObjClsAddNewTable.mPrAddNewTable _
                                      (UCase(lStrTableName) _
                                      , cboTableSpaceIndicator.Text _
                                      , Trim(cboClntSrvrIndc.Text) _
                                      , UCase(lStrShortName) _
                                      , txtTableDescription.Text _
                                      , mBlnTableExisted _
                                      , mBlnRGnrtTable)

    mObjClsAddNewTable.mPrAddTableDetails(UCase(lStrTableName), UCase(lStrShortName), ctlColumnsRecord)

    If mBlnRGnrtTable = True Then
      mObjClsAddNewTable.mPrSetPrimaryKey(mIntOldTableId, lIntTableId)
    End If

    ' ctlColumnsRecord.Rows.Clear()
    mBlnRGnrtTable = False

  End Sub

  Private Sub ctlColumnsRecord_CellMouseClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles ctlColumnsRecord.CellMouseClick

    If e.RowIndex = -1 Then
      Exit Sub
    End If

    If e.ColumnIndex = 0 Then

      If MsgBox("Delete column " & ctlColumnsRecord.Rows(e.RowIndex).Cells("clmClmName").Value & "?", MsgBoxStyle.YesNo, gCONST_MSG_HEADER) = MsgBoxResult.Yes Then
        ctlColumnsRecord.Rows.RemoveAt(e.RowIndex)
        ctlColumnsRecord.ClearSelection()
      End If

    Else
      txtColumnName.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmName").Value
      txtColumnDescription.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmDesc").Value
      cboColumnDataType.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmType").Value
      mColumnVrblRef = ctlColumnsRecord.CurrentRow.Cells("clmVariableReference").Value

      mBlnModifyCondition = True
    End If

  End Sub

  Private Sub ctlColumnsRecord_SelectionChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ctlColumnsRecord.SelectionChanged
    If mBlnModifyCondition = False Then Exit Sub
    mBlnModifyCondition = True
    If ctlColumnsRecord.SelectedRows.Count = 0 Then Exit Sub
    txtColumnName.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmName").Value
    txtColumnDescription.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmDesc").Value
    cboColumnDataType.Text = ctlColumnsRecord.CurrentRow.Cells("clmClmType").Value
    mColumnVrblRef = ctlColumnsRecord.CurrentRow.Cells("clmVariableReference").Value

  End Sub

  Private Sub cmdSelectColumnName_Click _
                (ByVal sender As System.Object _
               , ByVal e As System.EventArgs _
               ) Handles cmdSelectColumnName.Click, cmdMdSelectColumnName.Click

    Dim lIntStringLength As Integer = 0
    Dim lIntDataCatgLength As Integer = 0
    Dim lStrQuery As String = String.Empty
    Dim lIntColCnt As Integer = 0
    Dim lIntColIndex As Integer
    Dim lIntDataGridRowCount As Integer
    Dim lIntTableId As Integer = 0
    Dim lObjClsMemberProperties As clsMemberProperties
    Dim lObjComboSource As clsComboSource = Nothing
    Dim lStrTableName As String = String.Empty

    If mBlnRGnrtTable = False And mBlnModifyCondition = False Then
      If Trim(txtNewTableName.Text) = "" Then
        MsgBox("Please Enter table name")
        Exit Sub
      ElseIf Trim(txtTableShortName.Text) = "" Then
        MsgBox("Please Enter table short name")
        Exit Sub
      End If
      lStrTableName = Trim(txtNewTableName.Text)
    Else
      'mIntOldTableId = 0
      'lObjComboSource = cboTableNames.SelectedItem

      ''txtNewTableName.Text = cboTableNames.Text
      'txtNewTableName.Text = lObjComboSource.mPrpDisplayMember
      lIntTableId = mIntOldTableId
      lStrTableName = Trim(txtMdTableName.Text)
      'mIntOldTableId = lIntTableId
    End If

    mPrRefreshConn()
    'added by samuel 30.Oct
    'lStrQuery = "Select TABM_TABLE_ID ,TABM_TABLE_SHORT_NAME from TRDX_TABLES_MSTR where TABM_TABLE_NAME = '" + UCase(txtNewTableName.Text) + "'"
    lStrQuery = "Select TABM_TABLE_SHORT_NAME from TRDX_TABLES_MSTR where TABM_TABLE_NAME = '" + UCase(lStrTableName) + "'"
    lStrQuery = lStrQuery & " And TABM_TABLE_ID  = " & lIntTableId
    mCmdData = New OracleCommand(lStrQuery, con)
    mDrData = mCmdData.ExecuteReader

    If mDrData.HasRows Then
      While mDrData.Read
        If mBlnModifyCondition = False Then
          txtTableShortName.Text = mDrData.Item("TABM_TABLE_SHORT_NAME")
        Else
          txtMdTableShortName.Text = mDrData.Item("TABM_TABLE_SHORT_NAME")
        End If
      End While

      ' If mBlnRGnrtTable = False Then
      If mBlnModifyCondition = False Then
        If MsgBox("Do you want to modify the table existing with the same name?", MsgBoxStyle.YesNo, "Infomation") = MsgBoxResult.No Then
          Exit Sub
          'End If
        Else
          mBlnTableExisted = True



          If mBlnRGnrtTable = False And mBlnModifyCondition = False Then
            If UCase(Trim(txtTableShortName.Text)) <> UCase(mDrData("TABM_TABLE_SHORT_NAME")) Then
              MsgBox("The Table short name has been to changed to - " & mDrData("TABM_TABLE_SHORT_NAME") & _
                                " from the - " & txtTableShortName.Text & " that you entered .", MsgBoxStyle.OkOnly, "Information")
            End If
          End If


        End If
      Else
        mBlnTableExisted = True
      End If
    Else

      mBlnTableExisted = False

      'lStrQuery = "Select TABM_TABLE_SHORT_NAME from TRDX_TABLES_MSTR where TABM_TABLE_NAME = '" + UCase(txtNewTableName.Text) + "'"
      'lStrQuery = lStrQuery & " And TABM_TABLE_ID  = " & lIntTableId

      'mCmdData = New OracleCommand(lStrQuery, con)
      'mDrData = mCmdData.ExecuteReader

      'If mDrData.HasRows = True Then
      '  MsgBox("Table Short name already exists.Please Enter the correct unique short name.")
      '  Exit Sub
      'End If

      End If


      mObjFrmColumnNameSelection.Text = "Select Column Name"
      If mBlnTableExisted Then
        If mObjFrmColumnNameSelection.mBlnIsLoaded = False Then
          mObjFrmColumnNameSelection.mPrLoadExistedCol(UCase(lStrTableName), lIntTableId)
        End If
      End If

    If mBlnRGnrtTable = False Or mBlnModifyCondition = True Then
      mObjFrmColumnNameSelection.ShowDialog()
    End If

    'modify 30.Oct,Samuel Liu, need check ,important

    ' mBlnModifyCondition = False
    If mBlnRGnrtTable = True Then
      mObjFrmColumnNameSelection.mBlnFormClosed = False
    End If
    If mObjFrmColumnNameSelection.mBlnFormClosed = False Then

      lIntColCnt = mObjFrmColumnNameSelection.lstCols.Items.Count
      If lIntColCnt > 0 Then
        'first clear detail in grid
        'ctlColumnsRecord.Rows.Clear()

        For lIntColIndex = 0 To lIntColCnt - 1
          If mBlnModifyCondition = False Then
            With ctlColumnsRecord

              lIntDataGridRowCount = .Rows.Add() '.RowCount - 1
            End With
          Else
            lIntDataGridRowCount = ctlColumnsRecord.CurrentRow.Index
          End If


          lObjClsMemberProperties = mObjFrmColumnNameSelection.lstCols.Items.Item(lIntColIndex)

          Dim lObjClsDataCatgProperties As New clsMemberProperties

          With ctlColumnsRecord
            .Rows(lIntDataGridRowCount).Cells("clmDel").Value = "Del"
            .Rows(lIntDataGridRowCount).Cells("clmClmName").Value = UCase(lObjClsMemberProperties.mPrpDisplayMember)
            .Rows(lIntDataGridRowCount).Cells("clmClmType").Value = lObjClsMemberProperties.mPrpDataCatg

            cboColumnDataType.Text = lObjClsMemberProperties.mPrpDataCatg
            lObjClsDataCatgProperties = cboColumnDataType.SelectedItem

            .Rows(lIntDataGridRowCount).Cells("clmClmTypeValueMember").Value = lObjClsMemberProperties.mPrpValueMember
            .Rows(lIntDataGridRowCount).Cells("clmClmDesc").Value = txtColumnDescription.Text
            .Rows(lIntDataGridRowCount).Cells("clmNull").Value = IIf(lObjClsMemberProperties.mprpColNotNull = "Y", "Y", "N")
            .Rows(lIntDataGridRowCount).Cells("clmLength").Value = lObjClsDataCatgProperties.mPrpDataLength
            .Rows(lIntDataGridRowCount).Cells("clmPrecision").Value = lObjClsDataCatgProperties.mPrpDataPrecision
            .Rows(lIntDataGridRowCount).Cells("clmBasicDT").Value = lObjClsDataCatgProperties.mPrpBasicDataType
            .Rows(lIntDataGridRowCount).Cells("clmFEDataType").Value = lObjClsDataCatgProperties.mPrpFrontEndDataType
            .Rows(lIntDataGridRowCount).Cells("clmBEDataType").Value = lObjClsDataCatgProperties.mPrpBackEndDataType
            .Rows(lIntDataGridRowCount).Cells("clmFECategory").Value = lObjClsDataCatgProperties.mPrpFrontEndDataCatgClass
            .Rows(lIntDataGridRowCount).Cells("clmClientSrvIndc").Value = cboClntSrvrIndc.Text
            .Rows(lIntDataGridRowCount).Cells("clmVariableReference").Value = lObjClsMemberProperties.mPrpValueMember

          End With
        Next
      End If
    End If
    mObjFrmColumnNameSelection.lstCols.Items.Clear()
    Me.Focus()
  End Sub

  Private Sub cmdSetPrimaryKey_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSetPrimaryKey.Click
    Dim lObjFrmPrimaryKeySelection As New frmPrimaryKeySelection

    lObjFrmPrimaryKeySelection.cboTableNames.Text = Me.txtNewTableName.Text

    lObjFrmPrimaryKeySelection.ShowDialog()
  End Sub

  Private Sub cmdSelectTableName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdSelectTableName.Click
    Dim lIntTableNameLength As Integer = 0
    'Dim lArrTableNameElmnt As String() = Nothing
    'Dim lArrChrSeparator As Char() = {"_"}
    Dim lObjFrmTableNameSelection As New frmTableNameAbbreviation

    lObjFrmTableNameSelection.Text = "Select Table Name"

    lObjFrmTableNameSelection.ShowDialog()

    lIntTableNameLength = lObjFrmTableNameSelection.mStrColumnName.Length
    If lIntTableNameLength <> 0 Then
      'txtNewTableName.Text = cboClntSrvrIndc.Text & "_" & _
      '                        UCase(lObjFrmTableNameSelection.mStrColumnName. _
      '                        Substring(0, lIntTableNameLength - 1))

      txtNewTableName.Text = "TRDX_" + UCase(lObjFrmTableNameSelection.mStrColumnName. _
                                                    Substring(0, lIntTableNameLength - 1))

    End If
  End Sub


  Private Sub cmdGnrt_Click(ByVal sender As System.Object _
                          , ByVal e As System.EventArgs) Handles cmdGnrt.Click


    Dim lobjGnrtProCHedr As New clsGnrtProCHedr
    'added by Samuel 2007-10-19
    Dim lobjGnrtProCBody As New clsGnrtProCBody
    Dim lobjGnrtProCBodyCG As New clsGnrtProCBodyCG
    Dim lStrQuery As String
    Dim lObjComboSource As clsComboSource = Nothing
    Dim lIntTableId As Integer = 0

    clsobjGenClas = New clsGenClas

    If Trim(Me.txtNewTableName.Text) = "" Then
      MessageBox.Show("Table Name cannot be blank", gCONST_MSG_HEADER)
      txtNewTableName.Focus()
      Exit Sub
    End If

    lObjComboSource = cboTableNames.SelectedItem

    'txtNewTableName.Text = cboTableNames.Text
    txtNewTableName.Text = lObjComboSource.mPrpDisplayMember
    lIntTableId = lObjComboSource.mPrpValueMember

    lStrQuery = "Select TABM_TABLE_SHORT_NAME from TRDX_TABLES_MSTR where TABM_TABLE_NAME = '" + UCase(txtNewTableName.Text) + "'"
    lStrQuery = lStrQuery & " And TABM_TABLE_ID  = " & lIntTableId
    mCmdData = New OracleCommand(lStrQuery, con)
    mDrData = mCmdData.ExecuteReader

    If mDrData.HasRows Then
      While mDrData.Read
        txtTableShortName.Text = mDrData.Item("TABM_TABLE_SHORT_NAME")
      End While
    End If

    If clsobjGenClas.mFnGenerateClass(Me.txtNewTableName.Text _
                                    , clsobjGenClas.mFnGnrtClassName _
                                       (Me.txtNewTableName.Text) _
                                    , lIntTableId) = False Then

      MessageBox.Show("No file generated", gCONST_MSG_HEADER)
      Exit Sub
    Else
      If mBlnGnrtAll = False Then
        MessageBox.Show("Main File generated at C:\Table Classes", gCONST_MSG_HEADER)
      End If
    End If


    If clsobjGenClas.mFnGenerateHelperClass(Me.txtNewTableName.Text _
                                          , clsobjGenClas.mFnGnrtClassName _
                                            (Me.txtNewTableName.Text)) = False Then

    End If

    ' If UCase(cboClntSrvrIndc.Text) = "FRONT END" And mBlnGnrtAll = False Then

    If clsobjGenClas.mFnGenerateSQLCEScript(Me.txtNewTableName.Text _
                                          , clsobjGenClas.mFnGnrtClassName _
                                            (Me.txtNewTableName.Text)) = False Then
      MessageBox.Show("No file generated", gCONST_MSG_HEADER)
      Exit Sub
    Else
      If mBlnGnrtAll = False Then
        MessageBox.Show("SQLCE Script Generated at C:\SQLCE Script", gCONST_MSG_HEADER)
      End If
    End If

    ' Else

    If clsobjGenClas.mFnGnrtOracleScript(Me.txtNewTableName.Text _
                                          , clsobjGenClas.mFnGnrtClassName _
                                            (Me.txtNewTableName.Text)) = False Then
      MessageBox.Show("No file generated", gCONST_MSG_HEADER)
      Exit Sub
    Else
      If mBlnGnrtAll = False Then
        MessageBox.Show("Oracle Script Generated at C:\ORACLE Script", gCONST_MSG_HEADER)
      End If
    End If

    'End If

    'added by samuel 26 Oct.
    lobjGnrtProCHedr.mFnGenerateProCHedr(txtNewTableName.Text)
    'added by Samuel
    lobjGnrtProCBody.mFnGenerateProCBody(txtNewTableName.Text)
    lobjGnrtProCBodyCG.mFnGenerateProCBodyCG(txtNewTableName.Text)

    If mBlnGnrtAll = False Then
      MessageBox.Show("Check for Pro C Files Generated at C:\ProC File", gCONST_MSG_HEADER)
    End If

  End Sub

  Private Sub cmdGenAll_Click(ByVal sender As System.Object _
                                                       , ByVal e As System.EventArgs) _
                                                          Handles cmdGenAll.Click
    Dim i As Integer
    Dim j As Integer = 0
    Dim lObjComboSource As clsComboSource = Nothing

    If cboTableNames.Text = "ALL" Then

      mBlnGnrtAll = True

      For i = 2 To cboTableNames.Items.Count
        lObjComboSource = cboTableNames.Items.Item(i - 1)

        'txtNewTableName.Text = cboTableNames.Items.Item(i - 1).ToString()
        txtNewTableName.Text = lObjComboSource.mPrpDisplayMember
        cmdGnrt_Click(sender, e)
        j = j + 1
      Next

      MessageBox.Show("Files generated for all tables. Number of tables = " & j, gCONST_MSG_HEADER)

    Else

      mBlnGnrtAll = False
      lObjComboSource = cboTableNames.SelectedItem

      'txtNewTableName.Text = cboTableNames.Text
      txtNewTableName.Text = lObjComboSource.mPrpDisplayMember
      cmdGnrt_Click(sender, e)

    End If
  End Sub

  Private Sub cmdRgnrt_Click _
                (ByVal sender As System.Object _
               , ByVal e As System.EventArgs) Handles cmdRgnrt.Click

    mBlnRGnrtTable = True
    cmdSelectColumnName_Click(sender, e)

  End Sub

  'Private Sub cmdMdfy_Click( _
  '              ByVal sender As System.Object, _
  '              ByVal e As System.EventArgs) _
  '              Handles cmdMdfy.Click

  '  mBlnModifyCondition = True
  '  cmdSelectColumnName_Click(sender, e)

  'End Sub

  Private Sub cmdAddIndex_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAddIndex.Click
    frmIndexGenretor.mTableName = txtNewTableName.Text
    frmIndexGenretor.ShowDialog(Me)
  End Sub

  Private Sub cmdMdSelectTableName_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdMdSelectTableName.Click
    FrmDisplayGrid.sCallingPurpose = gENMU_PUEPOSE.Md_Tables
    FrmDisplayGrid.sCallingControl = "txtMdTableName"
    FrmDisplayGrid.ShowDialog()

    mBlnModifyCondition = True
    cmdSelectColumnName_Click(sender, e)
  End Sub

End Class